package com.example.myapplication;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.base.core.ui.BaseCallback;
import com.base.core.ui.BaseDialog;

public class CommitDialog extends BaseDialog {
    String title;
    BaseCallback callback;

    public CommitDialog(@NonNull Context context, String title) {
        super(context, Gravity.CENTER);
        this.title = title;
    }

    @Override
    protected void initView() {
        TextView tv_title = findViewById(R.id.tv_title);
        TextView tv_canle = findViewById(R.id.tv_canle);
        TextView tv_sure = findViewById(R.id.tv_sure);
        tv_title.setText(title);
        tv_canle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        tv_sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (callback != null) {
                    callback.response(0);
                }
            }
        });
    }

    public BaseCallback getCallback() {
        return callback;
    }

    public void setCallback(BaseCallback callback) {
        this.callback = callback;
    }

    @Override
    protected int getContentView() {
        return R.layout.dialog_commit;
    }
}
